
from apps.common.base.serializers import *
from apps.system.learn.models import *

class LearnBaseSerializer(BaseSerializer):

    class Meta:
        model = Learn
        fields = "__all__"

class LearnModelSerializer(BaseSerializer):

    lesseeModel = serializers.SerializerMethodField()
    def get_lesseeModel(self, obj):
        try:
            return {'id': obj.lessee.id, 'name': obj.lessee.name}
        except:
            return {}

    statusLabel = serializers.SerializerMethodField()

    def get_statusLabel(self, obj):
        try:
            return obj.get_status_display()
        except:
            return '未知'

    class Meta:
        model = Learn
        fields = "__all__"